﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>设备管理系统</title>
    <style type="text/css">
        * {
            font-family: 'Source Sans Pro','微软雅黑', sans-serif;
            font-size: 12px;
            margin: 0;
            padding: 0;
        }

        #nav:hover {
            background: #165585;
            cursor: pointer;
        }

        #menuTree {
            fit: fill;
        }

        #snav:hover {
            background: rgba(0, 0, 0, 0.25);
        }

        .loading_background {
            display: block;
            width: 100%;
            height: 100%;
            opacity: 0.0;
            filter: alpha(opacity=00);
            background: #fff;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 3000;
        }

        #loading {
            color: #666;
            font-size: 12pt;
            position: absolute;
            z-index: 3001;
            left: 42%;
            top: 40%;
            border: 2px solid #4A5B79;
            width: auto;
            padding: 8px 10px 7px 10px;
            background: #fff;
            display: none;
            cursor: pointer;
            /*-moz-border-radius: 8px;
            -webkit-border-radius: 8px;*/
            border-radius: 8px;
            box-shadow: 0 0 10px #ccc;
        }

            #loading span {
                font-size: 12pt;
            }
    </style>
    <link href="/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <link href="/Content/Site.css" rel="stylesheet" />
    <link href="/MsgBox/jquery.msgbox.css" rel="stylesheet" />
    <link href="/Easyui/themes/icon.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.8.2.min.js"></script>
@*    <script src="~/MsgBox/jquery.easyui.min.js"></script>*@
    <script src="/Easyui/jquery.easyui.min.js"></script>
@*    <script src="~/MsgBox/jquery.min.js"></script>*@
@*    <script src="~/MsgBox/jquery.easyui.min.js"></script>*@
    <script src="/MsgBox/jquery.msgbox.js"></script>
    <script src="/Scripts/jquery.validate.min.js"></script>
    <script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="/Scripts/jquery.msgProcess.js"></script>
    <script src="/Scripts/jquery.globalHelper.js"></script>
    <script src="/Easyui/easyui-lang-zh_CN.js"></script>
@*    <script src="/EasyUI/datagrid-filter.js"></script>*@
    @*<script src="/lhgdialog/lhgdialog.min.js"></script>*@
    <script type="text/javascript">

        $(function () {
            //1.初始化 选项卡容器
            $("#tabBox").tabs();

            //手风琴效果 后台生成
            $.ajax({
                url: "/admin/Manage/SysTab",
                type: "post",
                dataType: "json",
                success: function (data) {
                    //动态生成tab和ul菜单
                    $.each(JSON.parse(data), function(i, tab) {
                        sysTab(this.MenuTree, this.MenuUl);
                    });
                    $.each(JSON.parse(data), function (i, tab) {
                       
                        if (this.MenuId == 0) {
                            $("#ManageTree").after(" <ul id='FactoryTree'></ul>");
                            $("#FactoryTree").after("<ul id='ComputerTree'>/<ul></ul>");
                            sysTree("ManageTree", 0);
                            sysTree("FactoryTree", 1);
                            sysTree("ComputerTree", 2);
                            
                        } else {
                            sysTree(this.MenuName,this.MenuId);
                        }
                    });
                }
            });
          
         

            //页面动画
            $(window).load(function () {
                window.setTimeout(function () {
                    $('#ajax-loader').fadeOut();
                }, 100);
            });
            //2.初始化公共窗体（增删改查等的窗口）
            $("#commonWindow").window({
                iconCls: 'icon-vcard_edit',
                modal: true,
                minimizable: false,
                collapsible: false,
                resizable: false,
                maximizable: false,
                width: 1200,
                height: 580,
                title: '公共窗体',
                closed: true
            }).children("iframe").load(function () { //找到公共个窗体里的 iframe ，为其onload事件注册方法，关闭 进度条
                $.messager.progress("close");
            });

            $("#DepCommon").window({
                iconCls: 'icon-vcard_edit',
                modal: true,
                minimizable: false,
                collapsible: false,
                maximizable: false,
                resizable: false,
                width: 1200,
                height: 550,
                shadow: false,
                title: '公共窗体',
                closed: true
            }).children("iframe").load(function () { //找到公共个窗体里的 iframe ，为其onload事件注册方法，关闭 进度条
                $.messager.progress("close");
            });

        });


        //禁止退格键 作用于Firefox、Opera
        $(document).ready(function () {
            //禁止退格键 作用于Firefox、Opera
            document.onkeypress = banBackSpace;
            //禁止退格键 作用于IE、Chrome
            document.onkeydown = banBackSpace;
        });

        //生成tab
        function sysTab(a, b) {
            $('#accbox').accordion(
                'add', {
                    title: a,
                    content: b,
                    selected: false
                }
            );
        };

        function aa(id){
        $("#ManageTree").tree({
            url: "/admin/manage/getmenu/"+id,
            onLoadSuccess: function (node, jsonData) {
                //如果返回的消息 对象 包含 Status属性，说明是返回的 json消息，那么就调用 msgProcess方法 统一处理
                //                   不包含Status属性，说明 返回的是 节点json数据
                if (jsonData.Status) {
                    $.msgProcess(jsonData);
                }
            },
            onClick: nodeClick
        });
        };
     
        //生成菜单树
        function sysTree(name, id) {
            $("#" + name ).tree({
                url: "/admin/manage/getmenu/"+id,
                onLoadSuccess: function (node, jsonData) {
                    //如果返回的消息 对象 包含 Status属性，说明是返回的 json消息，那么就调用 msgProcess方法 统一处理
                    //                   不包含Status属性，说明 返回的是 节点json数据
                    if (jsonData.Status) {
                        $.msgProcess(jsonData);
                    }
                },
                onClick: nodeClick
            });
        }
        //1.节点点击方法 参数：被点击的节点对应的Json数据对象
        function nodeClick(nodeData) {
            //判断当前节点点击时是否要打开页面
            if (nodeData.attributes.isLink) {
                //1.1如果有和被点击节点同名的选项卡，就自动切换过去
                if (!$("#tabBox").tabs("exists", nodeData.text)) {
                    //调用选项卡组件的 add 方法，并传入参数对象{title}
                    $("#tabBox").tabs("add", {
                        title: nodeData.text, //选项卡标题
                        closable: true, //选项卡显示 关闭按钮
                        fit: true,                      
                        narrow:true,
                        iconCls: 'icon-page',
                        content: createContent(nodeData.attributes.url) //设置选项卡内容
                    });
                } else {
                    //判断 和被点击节点 同名的 选项卡 是否为选中状态
                    //获取选中选项卡的标题
                    var $curTab = $('#tabBox').tabs('getSelected');
                    var curTabTitle = $curTab.panel("options").title;
                    //如果是，则提示是否要刷新选项卡
                    if (nodeData.text == curTabTitle) {
                        $.messager.confirm('确认', "您确认想要刷新【" + curTabTitle + "】选项卡吗？", function (isOk) {
                            if (isOk) {
                                //从当前选中的 选项卡中 找到iframe
                                var $ifrObj = $("iframe", $curTab);
                                //重新设置iframe的src路径（刷新）
                                $ifrObj.attr("src", nodeData.attributes.url);
                            }
                        });
                    }
                        //如果不是，则设置为选中
                    else {
                        //设置 同名选项卡 为选中状态
                        $("#tabBox").tabs("select", nodeData.text);
                    }
                }
            }
        }

        //设置选项卡内容 tabs的iframe
        function createContent(url) {
            
            return '<iframe  scrolling="auto" frameborder="0" src="' + url + '"style="width:100%;height:100%;display:block;"></iframe>';
        }

        //页面效果
        function Replace() {
            location.reload();
            return false;
        }
        function HelpInfo() {
            $("#logHelp").dialog({
                title: '帮助信息',
                iconCls: "icon-tip",
                width: 260,
                height: 150,
                modal: true,
                
            });
        }
        function ModifyPwd() {
            $.globalHelper.showCommonWindow("修改密码", "/admin/Employee/ModifyPwd", 310, 180);
        }
        //退出界面
        function IndexOut() {
            $("#logOut").dialog({
                title: '系统提示',
                iconCls: "icon-tip",
                width: 260,
                height: 150,
                modal: true,
                buttons: [
                    {
                        text: '确认',
                        iconCls: 'icon-ok',
                        handler: function () {
                            $('#logOut').dialog('close');
                            //Loading(true, "正在退出系统...");
                            window.setTimeout(function () {
                                loginout();
                            }, 100);
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#logOut').dialog('close');
                        }
                    }
                ]
            });
        }

        //消息提示
        function ComSkipMsg(selectedRowData, url) {
            for (var i in selectedRowData) {
                var id = selectedRowData[i];
                if (id!=null) {
                    break;
                }
            };
            $("#logDel").dialog({
                title: '系统提示',
                iconCls: "icon-tip",
                width: 260,
                height: 150,
                modal: true,
                buttons: [
                    {
                        text: '确认',
                        iconCls: 'icon-ok',
                        handler: function () {
                            $.post(
                                url,
                                { delId: id },
                                function (data) {                                   
                                    $('#logDel').dialog('close');
                                    $.msgBoxObj.showInfo(data.data);
                                    $.globalHelper.reloadSeletecTabDataGrid();
                                }, "json");
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#logDel').dialog('close');
                        }
                    }
                ]
            });
        }

        //加载图片效果
        function Loading(bool, text) {
            var ajaxbg = window.top.$("#loading_background,#loading");
            if (!!text) {
                window.top.$("#loading").css("left", (top.$('body').width() - top.$("#loading").width()) / 2);
                window.top.$("#loading span").html(text);
            } else {
                window.top.$("#loading").css("left", "42%");
                window.top.$("#loading span").html("正在拼了命为您加载…");
            }
            if (bool) {
                ajaxbg.show();
            } else {
                ajaxbg.hide();
            }
        }

        //退出时候删除session
        function loginout() {
            window.top.location = "/admin/sys/LoginOut";
        }

        //处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外
        function banBackSpace(e) {
            //alert(event.keyCode)
            var ev = e || window.event; //获取event对象
            var obj = ev.target || ev.srcElement; //获取事件源
            var t = obj.type || obj.getAttribute('type'); //获取事件源类型
            //获取作为判断条件的事件类型
            var vReadOnly = obj.readOnly;
            var vDisabled = obj.disabled;
            //处理undefined值情况
            vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
            vDisabled = (vDisabled == undefined) ? true : vDisabled;
            //当敲Backspace键时，事件源类型为密码或单行、多行文本的，
            //并且readOnly属性为true或disabled属性为true的，则退格键失效
            var flag1 = ev.keyCode == 8 && (t == "password" || t == "text" || t == "textarea") && (vReadOnly == true || vDisabled == true);
            //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效
            var flag2 = ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea";
            //判断
            if (flag2 || flag1)
                //event.returnValue = false;//这里如果写 return false 无法实现效果 支持到ie10  ie11无效
                return false; //ie11下有效 谷歌有效
        }

    </script>

</head>
<body class="easyui-layout" data-options="fit:true,border:false">

    <div id="ajax-loader" style="position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; background: #fff; z-index: 100; overflow: hidden;">
        <img src="/EasyUI/themes/icons/ajax-loader.gif" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;" />
    </div>


    <div data-options="region:'north',split:false,noheader:true" style="height: 81px;width:100%; font-size: 10px; background: #1B659F;color:#ffffff;">
        <div class="logo fleft" style="margin-top: 15px; margin-left: 20px; width: 40%; float: left;">
            <img src="/EasyUI/themes/icons/loginlogo3.png" />
        </div>
        <div id="Headermenu" style="float: right; margin-right: 30px; ">
            <ul id=" topnav" style=" position: relative;">
                <li id="metnav" class="list" style="float: left; display: inline;">
                    <a id="nav" onclick="Replace();">
                        <span style="background: url(../../EasyUI/themes/icons/n1.png) no-repeat; display: block; margin: 20px 20px 2px 10px; width: 32px; height: 32px; overflow: hidden;"></span>系统首页
                    </a>
                </li>

                <li id="metnav" class="list droppopup" style="float: left; display: inline; ">
                    <a id="nav" onclick="HelpInfo();">
                        <span style=" background: url(../../EasyUI/themes/icons/n9.png) no-repeat; display: block; margin: 20px 20px 2px 8px; width: 32px; height: 32px; overflow: hidden; "></span>帮助中心
                    </a>
                </li>

                <li id="metnav" class="list" style="float: left; display: inline;">
                    <a id="nav" onclick="ModifyPwd();">
                        <span style=" background :url(../../EasyUI/themes/icons/n8.png) no-repeat; display: block; margin: 20px 10px 2px 8px; width: 32px; height: 32px; overflow: hidden; "></span>修改密码
                    </a>
                </li>
                <li id="metnav" class="list" style="float: left; display: inline;">
                    <a id="nav" onclick="IndexOut();">
                        <span style="background: url(../../EasyUI/themes/icons/n4.png) no-repeat; display: block; margin: 20px 15px 2px 20px; padding-left:10px; width: 32px; height: 32px; overflow: hidden; "></span>&nbsp&nbsp&nbsp安全退出
                    </a>
                </li>
            </ul>
        </div>

    </div>

    @*由后台根据权限动态加载生成*@
    <div id="accbox" class="easyui-accordion" data-options="region:'west',split:true,title:'导航菜单',iconCls:'icon-house'" style="width: 180px;margin:0;">

    </div>



<div data-options="region:'center',border:false">
        <div id="tabBox" data-options="fit:true,border:false"></div>
    </div>



    <div data-options="region:'south',split:false,noheader:true," style="height:22px; background: #1B659F;color:#ffffff">
        <div style="width: 30%; text-align: left; float: left; padding-top:2px;">
            &nbsp;技术支持：<a href="http://192.168.10.95" target="_blank" style="color: white;">中航电测仪器股份有限公司</a>
        </div>
        <div style="width: 35%; text-align: center; float: left; padding-top:2px;">
            CopyRight © 2016 By IT@@zemic.com.cn
        </div>
        <div style="width: 28%; text-align: right; float: right;">
            <div style="padding-right: 15px;">
                <div id="message" style="float: right; overflow: hidden; height: 20px; ">
                    <img id="imgmessage" title="无新消息提醒" src="/EasyUI/themes/icons/bottom_icon_message.png" />
                </div>
                <div style="float: right; overflow: hidden; height: 20px; padding:0 8px; ">
                    <img title='欢迎★@ViewBag.code@ViewBag.name★登录' src="/EasyUI/themes/icons/bottom_icon_usergroup.png" />
                </div>
            </div>
        </div>
    </div>




    <div id="commonWindow">
        <iframe id="comiframe" name="comiframe" scrolling="auto" frameborder="0" style="width: 100%; height: 100%; display: block; "></iframe>
    </div>

    <div id="logHelp" style=" text-align: center;line-height:30px;font-size:14px;">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp欢迎使用设备管理系统，使用中如有问题请联系生产部设备管理员刘亮，谢谢支持！</div>
    <div id="logOut" style=" text-align: center;line-height:75px;font-size:14px;"><img src="/EasyUI/themes/Icon32/attention.png" style="margin-bottom:-10px;padding-right:4px" />确定要退出系统？</div>
    <div id="logDel" style=" text-align: center;line-height:75px;font-size:14px;"><img src="/EasyUI/themes/Icon32/attention.png" style="margin-bottom:-10px;padding-right:4px" />是否要删除？</div>

    <div id="DepCommon" style="margin:0;padding:0">
        <iframe id="depiframe" name="depiframe" scrolling="auto" frameborder="0" style="width: 100%; height: 100%; display: block; "></iframe>
    </div>
    @*<script type="text/javascript">
            //注意：下面的代码是放在和iframe同一个页面调用,放在iframe下面
            $("#depiframe").load(function () {
                var mainheight = $(this).contents().find("body").height();
                $(this).height(mainheight);
            });
        </script>*@
    <!--载进度条start-->
    <div id="loading_background" class="loading_background" style="display: none;"></div>
    <div id="loading" onclick="Loading(false);">
        <img src="/EasyUI/themes/icons/loading.gif" style="vertical-align: middle;" />&nbsp;<span>正在拼了命为您加载…</span>&nbsp;
    </div>
    <div id="loadingGird">
        <img src="/EasyUI/themes/icons/loading.gif" style="vertical-align: middle;" />&nbsp;正在拼了命为您加载…&nbsp;
    </div>

</body>
</html>
